// JavaScript Document
// loading
var loading = 
{
	init:{
		style               : document.createElement("style"),
		loadingBox          : document.createElement("div"),
		iconBox             : document.createElement("em"),
		icon                : document.createElement("i"),
		background          : "rgba(0,0,0,.8)",//set background-color of loading
		icon_size           : "2rem",//set circle size of loading
		icon_borderWidth    : ".2rem",//set circle's border width of loading
		stator_borderColor  : "rgba(255,255,255,.2)",//set stator color of loading
		rotator_borderColor : "rgba(255,255,255,1)",//set rotator color of loading
		init:function(){
			loading.init.loadingBox.setAttribute("id","_loadingBox");
			loading.init.style.setAttribute("id","_loadingStyle");
			loading.init.style.type = "text/css";
			loading.init.style.innerHTML = 
			"._loadingBox {position:fixed;width:100%;height:100%;z-index:9999;left:0;top:0;background:"+loading.init.background+";}"+
			"._loadingBox_other {position:absolute;width:100%;height:100%;z-index:9999;left:0;top:0;background:"+loading.init.background+";} "+
			"._iconBox {position:fixed;display:block;width:"+loading.init.icon_size+";height:"+loading.init.icon_size+";border:"+loading.init.icon_borderWidth+" solid "+loading.init.stator_borderColor+";border-radius:100rem;margin:auto;left:0;right:0;top:0;bottom:0;} "+
			"._iconBox_other {position:absolute;display:block;width:"+loading.init.icon_size+";height:"+loading.init.icon_size+";border:"+loading.init.icon_borderWidth+" solid "+loading.init.stator_borderColor+";border-radius:100rem;margin:auto;left:0;right:0;top:0;bottom:0;}"+
			"._icon {display:block;width:100%;height:100%;border:"+loading.init.icon_borderWidth+" solid rgba(0,0,0,0);border-top:"+loading.init.icon_borderWidth+" solid "+loading.init.rotator_borderColor+";border-radius:10rem;position:absolute;left:-"+loading.init.icon_borderWidth+";top:-"+loading.init.icon_borderWidth+";-moz-animation:rotate .8s infinite linear;-webkit-animation:rotate .86s infinite linear;animation:rotate .8s infinite linear;}"+
			"@-moz-keyframes rotate{0%   "+
				"{-moz-transform:rotate(0deg);}100% {-moz-transform:rotate(-360deg);}}"+
			"@-webkit-keyframes rotate{0%   "+
				"{-webkit-transform:rotate(0deg);}100% {-webkit-transform:rotate(-360deg);}}"+
			"@keyframes rotate{0%   "+
				"{transform:rotate(0deg);}100% {transform:rotate(-360deg);}}";
		}
	},
	insert:function(insertTarget){
		loading.init.init();
		loading.init.loadingBox.setAttribute("class","_loadingBox");
		loading.init.iconBox.setAttribute("class","_iconBox");
		loading.init.icon.setAttribute("class","_icon");
		document.body.appendChild(loading.init.style);
		loading.init.iconBox.appendChild(loading.init.icon);
		loading.init.loadingBox.appendChild(loading.init.iconBox);
		
		if(!insertTarget)
		{
			document.body.appendChild(loading.init.loadingBox);
		}
		else
		{
			loading.init.loadingBox.setAttribute("class","_loadingBox_other");
			loading.init.iconBox.setAttribute("class","_iconBox_other");
			document.getElementById(insertTarget).appendChild(loading.init.loadingBox);
		}
	},
	remove:function(){
		document.getElementById("_loadingBox").remove();
		document.getElementById("_loadingStyle").remove();
	}
}